
function [br,ef] = BRall(gamma,B,X,C,xi,options,cmax,M)

if M == 0 % independent PRI, PVEM candidates

    [cMP,~,efMP] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,1,0),C(1,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cNA,~,efNA] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,2,0),C(2,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cPVEM,~,efPVEM] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,3,0),C(3,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cPRI,~,efPRI] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,4,0),C(4,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cPAN,~,efPAN] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,5,0),C(5,1),[],[],[],[],...
            0,cmax,[],[],options);

elseif M == 1 % joint PRI candidate
    
    xi(3,1) = -Inf;

    [cMP,~,efMP] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,1,1),C(1,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cNA,~,efNA] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,2,1),C(2,1),[],[],[],[],...
            0,cmax,[],[],options);

    cPVEM = 0; efPVEM = 0;

    [cPRI,~,efPRI] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,4,1),C(4,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cPAN,~,efPAN] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,5,1),C(5,1),[],[],[],[],...
            0,cmax,[],[],options);

else % joint PVEM candidate
    
    xi(4,1) = -Inf;

    [cMP,~,efMP] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,1,2),C(1,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cNA,~,efNA] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,2,2),C(2,1),[],[],[],[],...
            0,cmax,[],[],options);

    [cPVEM,~,efPVEM] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,3,2),C(3,1),[],[],[],[],...
            0,cmax,[],[],options);

    cPRI = 0; efPRI = 0;

    [cPAN,~,efPAN] = knitro_nlp(@(x)Payoffs(x,gamma,B,X,C,xi,5,2),C(5,1),[],[],[],[],...
            0,cmax,[],[],options);

end

br = [cMP,cNA,cPVEM,cPRI,cPAN]; % best responses
ef = [efMP,efNA,efPVEM,efPRI,efPAN]; % Knitro exit flags



